package mybatis.service.impl;

import java.util.List;

import org.apache.bcel.generic.RET;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import mybatis.dao.StudentDao;
import mybatis.entity.Student;
import mybatis.service.IMybatisService;
import mybatis.service.ITeacherService;

@Transactional(propagation = Propagation.REQUIRED)
@Service
public class MybatisServcieImpl implements IMybatisService {
    @Autowired
    private StudentDao studentDao;
    @Autowired
    private ITeacherService teacherService;

    @Override
    public List<Student> getStudents() {
        // TODO Auto-generated method stub
        List<Student> students = studentDao.queryInfoList4cache();
        students.get(0).setName("update name");
        return studentDao.queryInfoList4cache();
    }

    @Override
    public void update4cache(Long id, String name) {
        // TODO Auto-generated method stub
        teacherService.update(id, name);
        studentDao.update4cache();
        int i = 1 / 0;
    }

    @Override
    public Student queryInfo4cache(Long id) {
        return studentDao.queryInfo4cache(id);
    }

    @Override
    public List<Student> queryCollection(Long[] ids) {
        // TODO Auto-generated method stub
        return studentDao.queryCollection(ids, "fd");
    }

}
